package com.buka.communicate.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.buka.communicate.R;
import com.buka.communicate.adapter.SkillAdapter;
import com.buka.communicate.views.RoundProgressBar;
import com.jcodecraeer.xrecyclerview.ProgressStyle;

import net.neiquan.applibrary.base.BaseActivity;
import net.neiquan.applibrary.utils.ImageUtil;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/15 0015.
 */

public class SkillActivity extends BaseActivity {
    @InjectView(R.id.mRecylerView)
    RecyclerView mRecylerView;
    @InjectView(R.id.otherAbility)
    ImageView otherAbility;
    @InjectView(R.id.otherEffect)
    TextView otherEffect;
    @InjectView(R.id.mRoundProgress)
    RoundProgressBar mRoundProgress;
    @InjectView(R.id.mHitRate)
    TextView mHitRate;
    @InjectView(R.id.myAbility)
    ImageView myAbility;
    @InjectView(R.id.myEffect)
    TextView myEffect;
    @InjectView(R.id.hitRateHint)
    TextView hitRateHint;
    @InjectView(R.id.mEffect1)
    TextView mEffect1;
    @InjectView(R.id.mEffect2)
    TextView mEffect2;
    @InjectView(R.id.expendLogo1)
    ImageView expendLogo1;
    @InjectView(R.id.expendChosen1)
    FrameLayout expendChosen1;
    @InjectView(R.id.expendNum1)
    TextView expendNum1;
    @InjectView(R.id.successRate1)
    TextView successRate1;
    @InjectView(R.id.expendLogo2)
    ImageView expendLogo2;
    @InjectView(R.id.expendChosen2)
    FrameLayout expendChosen2;
    @InjectView(R.id.expendNum2)
    TextView expendNum2;
    @InjectView(R.id.successRate2)
    TextView successRate2;
    @InjectView(R.id.expendLogo3)
    ImageView expendLogo3;
    @InjectView(R.id.expendChosen3)
    FrameLayout expendChosen3;
    @InjectView(R.id.expendNum3)
    TextView expendNum3;
    @InjectView(R.id.successRate3)
    TextView successRate3;
    @InjectView(R.id.singleAttack)
    ImageView singleAttack;
    @InjectView(R.id.groupAttack)
    ImageView groupAttack;
    @InjectView(R.id.punishTa)
    CardView punishTa;

    @Override
    public int getRootViewId() {
        return R.layout.activity_skill;
    }

    @Override
    public void setViews() {
        setTitleTv("你想对他做什么?");
        initRecylerView();
        Spanned spanned = Html.fromHtml("命中 <font color='#00ffff'>+90.00</font>  闪避 <font color='#00ffff'>+63.00</font>");
        otherEffect.setText(spanned);
        myEffect.setText(spanned);
        mRoundProgress.setProgress(61);
    }

    private void initRecylerView() {
        StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3,
                StaggeredGridLayoutManager.VERTICAL);
        layoutManager.setOrientation(StaggeredGridLayoutManager.VERTICAL);
        mRecylerView.setLayoutManager(layoutManager);
        mRecylerView.setAdapter(new SkillAdapter(this,null));
    }

    @Override
    public void initData() {
        ImageUtil.loadPicNet("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1510753423045&di=5a6dba7098f126a237d61a5372845252&imgtype=0&src=http%3A%2F%2Fpic36.nipic.com%2F20131219%2F5129009_103930508192_2.jpg",expendLogo1);
        ImageUtil.loadPicNet("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1510753423045&di=5a6dba7098f126a237d61a5372845252&imgtype=0&src=http%3A%2F%2Fpic36.nipic.com%2F20131219%2F5129009_103930508192_2.jpg",expendLogo2);
        ImageUtil.loadPicNet("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1510753423045&di=5a6dba7098f126a237d61a5372845252&imgtype=0&src=http%3A%2F%2Fpic36.nipic.com%2F20131219%2F5129009_103930508192_2.jpg",expendLogo3);
    }

    @OnClick({R.id.hitRateHint, R.id.expendChosen1, R.id.expendChosen2, R.id.expendChosen3, R.id.singleAttack, R.id.groupAttack, R.id.punishTa})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.hitRateHint:
                startActivity(new Intent(SkillActivity.this,SkillDetailActivity.class));
                break;
            case R.id.expendChosen1:
                changeChosenBg(expendChosen1);
                break;
            case R.id.expendChosen2:
                changeChosenBg(expendChosen2);
                break;
            case R.id.expendChosen3:
                changeChosenBg(expendChosen3);
                break;
            case R.id.singleAttack:
                break;
            case R.id.groupAttack:
                break;
            case R.id.punishTa:
                break;
        }
    }

    private void changeChosenBg(FrameLayout mChosenFL){
        expendChosen1.setBackground(null);
        expendChosen2.setBackground(null);
        expendChosen3.setBackground(null);
        mChosenFL.setBackground(getResources().getDrawable(R.drawable.shape_blue_dashed));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
    }
}
